
import Cookies from 'js-cookie'
export function getPageCount(pagePath){
    // const counts = JSON.parse(localStorage.getItem('pageCounts') || '{}')
    const countsStr = Cookies.get('pageCounts')
    const counts = countsStr ? JSON.parse(countsStr) : {}
    return counts[pagePath] || { count: 0, time: null }
}

export function setPageCount(pagePath, count){
    // const counts = JSON.parse(localStorage.getItem('pageCounts') || '{}')
    const countsStr = Cookies.get('pageCounts')
    const counts = countsStr ? JSON.parse(countsStr) : {}
    counts[pagePath] = {count}
    // localStorage.setItem('pageCounts', JSON.stringify(counts))
    Cookies.set('pageCounts', JSON.stringify(counts)) // 有效期为365天 , { expires: 365 }

}
